package com.sohu.peak.gallery.web;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.sohu.peak.util.Logger;
import com.sohu.peak.util.PeakSessionFactory;

    
public class SpringServlet extends HttpServlet {
    protected final Logger log = new Logger();
    

	public void init() throws ServletException {
        super.init();
    
        WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
     
        SpringContextManager.getInstance().setApplicationContext(context);
    	
    	
    	PeakSessionFactory.instance().getCurrentSession().beginTransaction();
    	
	
	
		 PeakSessionFactory.instance().getCurrentSession().getTransaction().commit();
    	String cid = getServletConfig().getInitParameter("cid");
    	
    	try{
    	if(cid!=null){
    		com.sohu.peak.gallery.domain.Constants.GlobCateId=Long.parseLong(cid);
    	}
    	}catch(Exception e){
    		log.error("init error",e);
    	}
    	log.debug("GlobCateId====="+com.sohu.peak.gallery.domain.Constants.GlobCateId);
    }  

}
